<?php
/**发放微店优惠券页面*/
$memberId = $_POST['memberId'];
$couponsType = $_POST['couponsType'] ? $_POST['couponsType'] : '3';
$mysign = $_POST['mysign'];
require_once ("config.php");

$cod_verify = new CodVerify($cod_config['key']);
$verify_result = $cod_verify->md5Verify($memberId, $mysign);
if ($verify_result && in_array($couponsType, $couponsTypeArr)) {
    include_once ($config["webroot"] . "/module/micro_shop/includes/plugin_coupons_class.php");
    $couponsObj = new Coupons();
    $res = $couponsObj->createOnePackage($memberId, $couponsConfigId[$couponsType]);
    if ($res) {
        echo "success"; // 请不要修改或删除
    } else {
        //生成失败
        echo "fail";
    }
} else {
    
    // //验证失败
    echo "fail";
    
    // 调试用，写文本函数记录程序运行情况是否正常
    // logResult("这里写入想要调试的代码变量值，或其他运行的结果记录");
}

class CodVerify
{

    var $signKey;

    function __construct($signKey)
    {
        $this->signKey = $signKey;
    }

    function md5Verify($prestr, $sign)
    {
        $prestr = $prestr . $this->signKey;
        $mysgin = md5($prestr);
        
        if ($mysgin == $sign) {
            return true;
        } else {
            return false;
        }
    }
}




